package com.heima.wemedia.feign;

import com.heima.apis.wemedia.IWeMediaClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.wemedia.service.WmChannelService;
import com.heima.wemedia.service.WmUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class WeMediaClient implements IWeMediaClient {
    @Autowired
    private WmUserService service;
    @Autowired
    private WmChannelService channelService;
    @Override
    @PostMapping("/api/v1/wemedia/saveUser")
    public ResponseResult saveWeMediaUser(@RequestBody ApUser apUser) {
        log.info("开始处理文章：{}",apUser);
        return service.insert(apUser);
    }

    @Override
    @GetMapping("/api/v1/channel/list")
    public ResponseResult getChannel() {
        return channelService.channels();
    }
}
